package com.joysuch.wwyt.log.service.impl;

import com.joysuch.wwyt.log.entity.ApiLog;
import com.joysuch.wwyt.log.mapper.ApiLogMapper;
import com.joysuch.wwyt.log.service.ApiLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zr
 * @since 2021-08-09
 */
@Service
@Slf4j
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements ApiLogService {
    
    @Autowired
    private ApiLogMapper apiLogMapper;
    
    @Override
    public void saveApiLog(String httpUrl, String taskCode,Long operator,String userSn, String requestBody, String response, Integer resultStatus,String requestId) {
        try {
            ApiLog apiLog= ApiLog.builder().apiUrl(httpUrl)
                    .bizCode(taskCode)
                    .operator(operator)
                    .userSn(userSn)
                    .requestBody(requestBody)
                    .response(response)
                    .resultStatus(resultStatus)
                    .requestId(requestId)
                    .build();
            // 2023/06/13 日志容量太大，取消保存
            //apiLogMapper.insert(apiLog);
        }catch (Exception e){
            log.error("save log failed: {}",e.getMessage());
        }
    }
}
